﻿
@{
    ViewBag.Title = "订餐计划-新增";
    Layout = "~/Views/Shared/_Layout.cshtml";;
}
<h2>@ViewBag.Title</h2>
<script src="~/Scripts/Erp/dateTime.js"></script>
<script src="~/Scripts/Erp/defineDataTable.js"></script>
<script type="text/javascript">
        $(document).ready(function () {
            var nowTime = new Date();  
            for (var i = 0; i <@ViewData["day"];i++)
            {
                var trHtml ='<tr class="trOK"><td class="td1">' + nowTime.Format("yyyy-MM-dd") + '</td><td class="td2">';
                trHtml += '<input checked= "checked"  type= "checkbox">早餐</input><br />'
                trHtml += '<input checked= "checked"  type= "checkbox">午餐</input><br />'
                trHtml += '<input checked= "checked"  type= "checkbox">晚餐</input><br />'
                trHtml += '<input checked= "checked"  type= "checkbox">宵夜</input></td></tr>';

                AddTableTr( trHtml);
                nowTime.setDate(nowTime.getDate() + 1); 
            }

            $(":button").click(function () {
                var allString = "";
                $(".trOK").each(function () {
                    var tempString = "";
                    if ($(this).find(".td2").find(":checkbox:eq(0)").prop("checked") == true)
                    {
                        tempString += ".0";
                    }
                    if ($(this).find(".td2").find(":checkbox:eq(1)").prop("checked") == true) {
                        tempString += ".1";
                    }
                    if ($(this).find(".td2").find(":checkbox:eq(2)").prop("checked") == true) {
                        tempString += ".2";
                    }
                    if ($(this).find(".td2").find(":checkbox:eq(3)").prop("checked") == true) {
                        tempString += ".3";
                    }
                    if (tempString != "")
                    {
                        allString += ($(this).find(".td1").text() + tempString + ";");
                    }
                });
                $("#submitValue").val(allString);
                $("form").submit();
            });
        });
</script>

<table class="table" id="tableDetail">
    <tr>
        <th>
            日期
        </th>
        <th>
            用餐时段
        </th> 
    </tr>

</table>
<form action="/BookDinner/DinnerPlanNewInsert" method="post">
    <input type="hidden" id="submitValue" name="submitValue" />
    <input type="button" value="提交" class="btn btn-default" />
</form>
